package unwdmi.dto;

import java.sql.*;

/**
 * A JAVA object for handling measurment data
 * @author Stephan E G Veenstra
 * @version 0.0.1
 */
public class Measurement {
	public Integer station;
	public String date;
	public String time;
	public Double temperature;
	public Double dewpoint;
	public Double airpreasureStation;
	public Double airpreasureSea;
	public Double visibility;
	public Double windSpeed;
	public Double rainfall;
	public Double snowfall;
	
	public Boolean freeze = false;
	public Boolean rain = false;
	public Boolean snow = false;
	public Boolean hail = false;
	public Boolean thunder = false;
	public Boolean tornado = false;
	
	public Double cloud;
	public Integer windDirection;
	
	/**********************
	 *** GLOBAL METHODS ***
	 *********************/
	
	public Measurement() {};
	
	public Measurement(Integer stn, String date, String time, Double temp, Double dewp, Double stp, Double slp, Double visib, Double wdsp, Double prcp, Double sndp, String frshtt, Double cldc, Integer wnddir) {
		this.setSTN(stn);
		this.setDATE(date);
		this.setTIME(time);
		this.setTEMP(temp);
		this.setDEWP(dewp);
		this.setSTP(stp);
		this.setSLP(slp);
		this.setVISIB(visib);
		this.setWDSP(wdsp);
		this.setPRCP(prcp);
		this.setSNDP(sndp);
		this.setFRSHTT(frshtt);
		this.setCLDC(cldc);
		this.setWNDDIR(wnddir);
	};
	
	@Override
	public String toString() {
		String measurement = "";
		measurement += "\n Station \t\t : " + this.station;
		measurement += "\n Date \t\t\t : " + this.date;
		measurement += "\n Time \t\t\t : " + this.time;
		measurement += "\n Temperature \t\t : " + this.temperature;
		measurement += "\n Dew-Point \t\t : " + this.dewpoint;
		measurement += "\n Air-Preasure (station)  : " + this.airpreasureStation;
		measurement += "\n Air-Preasure (sea) \t : " + this.airpreasureSea;
		measurement += "\n Visibility \t\t : " + this.visibility;
		measurement += "\n Wind-Speed \t\t : " + this.windSpeed;
		measurement += "\n Rain-Fall \t\t : " + this.rainfall;
		measurement += "\n Snow-Fall \t\t : " + this.snowfall;
		measurement += "\n Frozen \t\t : " + this.freeze;
		measurement += "\n Rain \t\t\t : " + this.rain;
		measurement += "\n Snow \t\t\t : " + this.snow;
		measurement += "\n Thunder \t\t : " + this.thunder;
		measurement += "\n Tornado \t\t : " + this.tornado;
		measurement += "\n Cloudy \t\t : " + this.cloud;
		measurement += "\n Wind-Direction \t : " + this.windDirection;
		return measurement;
	};
	
	/**********************
	 *** SETTER METHODS ***
	 *********************/
	
	public void setSTN(Integer stn) {
		this.station = stn;
	};
	
	public void setDATE(String date) {
		this.date = date;
	};
	
	public void setTIME(String time) {
		this.time = time;
	};
	
	public void setTEMP(Double temp) {
		this.temperature = temp;
	};
	
	public void setDEWP(Double dewp) {
		this.dewpoint = dewp;
	};
	
	public void setSTP(Double stp) {
		this.airpreasureStation = stp;
	};
	
	public void setSLP(Double slp) {
		this.airpreasureSea = slp;
	};
	
	public void setVISIB(Double visib) {
		this.visibility = visib;
	};
	
	public void setWDSP(Double wdsp) {
		this.windSpeed = wdsp;
	};
	
	public void setPRCP(Double prcp) {
		this.rainfall = prcp;
	};
	
	public void setSNDP(Double sndp) {
		this.snowfall = sndp;
	};
	
	public void setCLDC(Double cldc) {
		this.cloud = cldc;
	};
	
	public void setFRSHTT(String frshtt) {
		this.freeze = Integer.parseInt(frshtt.substring(0,1)) == 1 ? true : false;
		this.rain = Integer.parseInt(frshtt.substring(1,2)) == 1 ? true : false;
		this.snow = Integer.parseInt(frshtt.substring(2,3)) == 1 ? true : false;
		this.hail = Integer.parseInt(frshtt.substring(3,4)) == 1 ? true : false;
		this.thunder = Integer.parseInt(frshtt.substring(4,5)) == 1 ? true : false;
		this.tornado = Integer.parseInt(frshtt.substring(5,6)) == 1 ? true : false;
	};
	
	public void setWNDDIR(Integer wnddir) {
		this.windDirection = wnddir;
	};
	
	/**********************
	 *** GETTER METHODS ***
	 *********************/
	
	public Integer getSTN() {
		return this.station;
	};
	
	public Date getDATE() {
		return Date.valueOf(this.date);
	};
	
	public Time getTIME() {
		return Time.valueOf(this.time);
	};
	
	public String getDATETIME() {
		return this.date + " " + this.time;
	};
	
	public Double getTEMP() {
		return this.temperature;
	};
	
	public Double getDEWP() {
		return this.dewpoint;
	};
	
	public Double getSTP() {
		return this.airpreasureStation;
	};
	
	public Double getSLP() {
		return this.airpreasureSea;
	};
	
	public Double getVISIB() {
		return this.visibility;
	};
	
	public Double getWDSP() {
		return this.windSpeed;
	};
	
	public Double getPRCP() {
		return this.rainfall;
	};
	
	public Double getSNDP() {
		return this.snowfall;
	};
	
	public String getFRSHTT() {
		String frshtt = "";
		frshtt += this.freeze  ? "1" : "0";
		frshtt += this.rain    ? "1" : "0";
		frshtt += this.snow    ? "1" : "0";
		frshtt += this.hail    ? "1" : "0";
		frshtt += this.thunder ? "1" : "0";
		frshtt += this.tornado ? "1" : "0"; 
		return frshtt;
	};
	
	public Double getCLDC() {
		return this.cloud;
	};
	
	public Integer getWNDDIR() {
		return this.windDirection;
	};
	
	
}
